import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const getters = {
  getAre: (state) => state.are,
  getNotice:(state) => state.notice,
  getRong:(state) => state.rong,
  getFriends:(state) => state.friends,
  getRecordmsg:(state) => state.currentMsg,
  getconnectDb:(state) => state.connectDb,
  getAllmsg:(state) => state.allMsg,
  getunreadNum:(state) => state.unreadNum,
  getsingleNum:(state) => state.singleNum,
}

export default new Vuex.Store({
  state: {
    are:'+86',
    notice:'',
    rong:'',
    friends:[],
    connectDb:false,
    currentMsg:'',
    allMsg:[],
    unreadNum:0,
    singleNum:[],
    test:[]
  },
  getters,
  mutations: {
    setunreadNum(state,data){//设置未读消息数量
      state.unreadNum = data
    },
    setsingledNum(state,data){//设置单个未读消息数量
      state.singleNum = data
    },
    setRecoredmsg(state,data){//设置当前聊天消息
      state.currentMsg = data
    },
    setAllmsg(state,data){
      state.allMsg = state.test.concat(data);
    },
    setAre(state,data){
      state.are = data
    },
    setfriends(state,data){
      state.friends = data
    },
    setNotice(state,data){
      state.notice = data
    },
    setRong(state,data){
      state.rong = data
    },
    setconnectDb(state,data){
      state.connectDb = data
    },
  },
  actions: {

  }
})
